<?php
	
	require_once (dirname(__FILE__)."/../app.render.php");
	
	global $database;
	
	/*		AUTODETECTAR-FACEBOOK		*/
	if(isset($_POST['facebook']) && $_POST['facebook'] != '' ){
		$userEmail 			= $_POST['facebook'];
		$userRegistrados	= $database->select("SELECT * FROM users WHERE email='". $userEmail ."' ");
				
		if($userRegistrados){
			if((!isset($_SESSION['userid'])) or ($_SESSION['userid'] == '' ) ) {
				$_SESSION['userid'] = $userRegistrados[0]['id'];
				echo 1;
				exit(0);
			} else {
				echo 0;
				exit(0);			
			}
		}
	}
	/*		FIN AUTODETECTAR-FACEBOOK	*/	
?>